import fetch from 'common/src/utils/fetch';
import baseUrl from './env';
import UTILS from "common/src/utils/utils";
// 查询申报列表
function  projectListPage (data) {
  return fetch({
      url: baseUrl + "/manage/project/getPage",
      method: 'post',
      data
  });
}
// 新增申报列表
function  projectListPageAdd (data) {
  return fetch({
      url: baseUrl + "/manage/project/apply",
      method: 'post',
      data
  });
}
// 重新提交申报列表
function  projectListPageReSubmit (data) {
  return fetch({
      url: baseUrl + "/manage/project/reSubmit",
      method: 'post',
      data
  });
}
// 查看申报列表
function  projectListgetDetail (data, submitMission) {
  submitMission = submitMission ? submitMission : null
  return fetch({
      url: baseUrl + "/manage/project/getDetail?id="+data+'&submitMission='+submitMission,
      method: 'get'
  });
}
// 查看学院审核
function  approveApplyPage (data) {
  return fetch({
      url: baseUrl + "/manage/project/approveApplyPage",
      method: 'post',
      data
  });
}
// 查询申报时间
function getReportTime () {
  return fetch({
    url: baseUrl + "/manage/applyTime/getTime",
    method: 'get'
  });
}
// 设置申报时间
function setReportTime (data) {
  return fetch({
    url: baseUrl + "/manage/applyTime/setTime",
    method: 'post',
    data
});
}
// 审核之前接口
function  getEnterApprove (data) {
  return fetch({
      url: baseUrl + "/manage/project/enterApprove?id="+data.id,
      method: 'get'
  });
}
// 学院审核通过/不通过
function  getCollegeApprove (data) {
  return fetch({
      url: baseUrl + "/manage/project/collegeApprove?id="+data.id+'&isPass='+data.isPass+'&type='+data.type+'&reason='+data.reason,
      method: 'get'
  });
}
// 获取审核列表
function  getApproveList (data) {
  return fetch({
      url: baseUrl + "/manage/project/getApproveList?id="+data.id+'&type='+data.type,
      method: 'get'
  });
}
// 任务书审核列表
function  getPlanApprovePage (data) {
  return fetch({
      url: baseUrl + "/manage/project/getPlanApprovePage",
      method: 'post',
      data
  });
}
// 获取各项目任务书经费类别统计
function getSomeProjectStatis(data) {
  return fetch({
    url: baseUrl + "/manage/project/getPlanBudgetStatistic",
    method: 'post',
    data
  });
}
// 任务书审核列表导出
function  exportPlanList (data) {
  return fetch({
    url: baseUrl + "/manage/project/exportPlanList",
    method: 'post',
    responseType: 'blob',
    data
  }).then(res => {
    UTILS.downloadFile(res, '查看任务书', 'application/vnd.ms-excel;charset=utf-8');
  });
}
// 学校审核
function  schoolApprove (data) {
  return fetch({
      url: baseUrl + "/manage/project/schoolApprove",
      method: 'post',
      data
  });
}
// 管理员评分查询
function  managerGetListPage (data) {
  return fetch({
      url: baseUrl + "/manage/projectscore/manager/getListPage",
      method: 'post',
      data
  });
}
// 管理员评分提交
function  managerGetListAdd (data) {
  return fetch({
      url: baseUrl + "/manage/projectscore/manager/add",
      method: 'post',
      data
  });
}
// 管理员评分导出
function  postExportPictureDownload (data) {
  return fetch({
    url: baseUrl + "/manage/projectscore/manager/download",
    method: 'post',
    responseType: 'blob',
    data
  }).then(res => {
    UTILS.downloadFile(res, '管理员评分', 'application/vnd.ms-excel;charset=utf-8');
  });
}
// 专家组评分查询
function  specialistGetListPage (data) {
  return fetch({
      url: baseUrl + "/manage/projectscore/specialist/getListPage",
      method: 'post',
      data
  });
}
// 专家组评分提交
function  managerSpecialistListAdd (data) {
  return fetch({
      url: baseUrl + "/manage/projectscore/specialist/add",
      method: 'post',
      data
  });
}
// 专家组评分导出
function  postExportSpecialistDownload (data) {
  return fetch({
    url: baseUrl + "/manage/projectscore/specialist/download",
    method: 'post',
    responseType: 'blob',
    data
  }).then(res => {
    UTILS.downloadFile(res, '专家组评分', 'application/vnd.ms-excel;charset=utf-8');
  });
}
// 审核预算导出
function  postExportexportApproveList (data) {
  return fetch({
    url: baseUrl + "/manage/project/exportApproveList",
    method: 'post',
    responseType: 'blob',
    data
  }).then(res => {
    UTILS.downloadFile(res, '审核预算', 'application/vnd.ms-excel;charset=utf-8');
  });
}
// 预算审核列表
function  getApproveBudgetPage (data) {
  return fetch({
      url: baseUrl + "/manage/project/getApproveBudgetPage",
      method: 'post',
      data
  });
}
// 调整预算接口
function adjustTheBudget (data) {
  return fetch({
    url: baseUrl + "/manage/project/adjustApprovedBudget",
    method: 'post',
    data
  });
}
// 查看审核预算回填
function  getApprovedBudgetByProject (data) {
  return fetch({
      url: baseUrl + "/manage/project/getApprovedBudgetByProject?id="+data,
      method: 'get'
  });
}
// 审核预算立项/不立项
function  getApprovedBudgetBySetUp (data) {
  return fetch({
      url: baseUrl + "/manage/project/setUp?id="+data.id+'&setUp='+data.setUp,
      method: 'get'
  });
}
// 审核预算页面，获取审核后总预算
function  getApproveSum (data) {
  return fetch({
      url: baseUrl + "/manage/project/getApproveSum?year="+data.year+'&id='+data.id,
      method: 'get'
  });
}
// 预算审核列表页面，表头上方获取预算统计信息
function  getApproveBudgetStatistic (data) {
  return fetch({
      url: baseUrl + "/manage/project/getApproveBudgetStatistic?year="+data.year+'&name='+data.name+'&typeId='+data.typeId+'&comLevel='+data.comLevel+'&college='+data.college+'&status='+data.status,
      method: 'get'
  });
}
// 任务书提交
function  managerSpecialSubmitPlan (data) {
  return fetch({
      url: baseUrl + "/manage/project/submitPlan",
      method: 'post',
      data
  });
}
// 审核预算
function  postApproveBudget (data) {
  return fetch({
      url: baseUrl + "/manage/project/approveBudget",
      method: 'post',
      data
  });
}
// 任务书导出
function  exportWordZip (data) {
    return fetch({
        url: baseUrl + "/manage/project/exportWordZip?id="+data.id+'&type='+data.type,
        method: 'get',
        responseType: 'blob',
        data
    }).then(res => {
      UTILS.downloadFile(res, data.type === 1 ? '申报书' : '任务书', 'application/msword;charset=utf-8');
    });
}

export default {
  projectListgetDetail: projectListgetDetail,
  projectListPage: projectListPage,
  projectListPageAdd: projectListPageAdd,
  projectListPageReSubmit: projectListPageReSubmit,
  approveApplyPage: approveApplyPage,
  getReportTime: getReportTime,
  setReportTime: setReportTime,
  getCollegeApprove: getCollegeApprove,
  getApproveList: getApproveList,
  getPlanApprovePage: getPlanApprovePage,
  getSomeProjectStatis: getSomeProjectStatis,
  exportPlanList: exportPlanList,
  schoolApprove: schoolApprove,
  managerGetListPage: managerGetListPage,
  managerGetListAdd: managerGetListAdd,
  postExportPictureDownload: postExportPictureDownload,
  specialistGetListPage: specialistGetListPage,
  managerSpecialistListAdd: managerSpecialistListAdd,
  postExportSpecialistDownload: postExportSpecialistDownload,
  getApproveBudgetPage: getApproveBudgetPage,
  adjustTheBudget: adjustTheBudget,
  getApprovedBudgetByProject: getApprovedBudgetByProject,
  getApprovedBudgetBySetUp: getApprovedBudgetBySetUp,
  postExportexportApproveList: postExportexportApproveList,
  managerSpecialSubmitPlan: managerSpecialSubmitPlan,
  postApproveBudget: postApproveBudget,
  getApproveSum: getApproveSum,
  getApproveBudgetStatistic: getApproveBudgetStatistic,
  getEnterApprove: getEnterApprove,
  exportWordZip: exportWordZip
};